<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a="http://richfaces.org/a4j"
	xmlns:birt="http://jsf4birt.components"
	template="/templates/template.xhtml">
    
<ui:define name="title">#{msg['menu.titulo.reporteCunamas.presupuestal']}</ui:define>
<ui:define name="body">

    <h:form id="budgetReport" styleClass="edit">
    
    	<h:outputText value="#{budgetInputDataLoadController.loadDefaultValues()}"/>

        <rich:simpleTogglePanel label="#{msg['budgetReport.title']}" switchType="ajax">
        	
        	<table width="100%">
        	
       			<tr>
        			<td>
        				<h:outputText value="#{msg['general.year']}" />
        			</td>
        			<td>
        				<h:inputText value="#{budgetInputDataLoadController.anio}" size="5"/>
        			</td>
        			<td>
        				<h:outputText value="#{msg['general.month']}" />
        			</td>
        			<td>
						<h:selectOneMenu id="cmbMes"
							value="#{budgetInputDataLoadController.mes}"
							styleClass="cmbForm">
							<f:selectItem itemLabel="--seleccione--" itemValue="00" />
							<f:selectItem itemLabel="Enero" itemValue="01" />
							<f:selectItem itemLabel="Febrero" itemValue="02" />
							<f:selectItem itemLabel="Marzo" itemValue="03" />
							<f:selectItem itemLabel="Abril" itemValue="04" />
							<f:selectItem itemLabel="Mayo" itemValue="05" />
							<f:selectItem itemLabel="Junio" itemValue="06" />
							<f:selectItem itemLabel="Julio" itemValue="07" />
							<f:selectItem itemLabel="Agosto" itemValue="08" />
							<f:selectItem itemLabel="Septiembre" itemValue="09" />
							<f:selectItem itemLabel="Octubre" itemValue="10" />
							<f:selectItem itemLabel="Noviembre" itemValue="11" />
							<f:selectItem itemLabel="Diciembre" itemValue="12" />
						</h:selectOneMenu>
        			</td>
        		</tr>
        		
        		<tr>
        			<td colspan="10">
        				<hr />
        			</td>
        		</tr>
        		
        		<!-- insumo presupuesto -->
        		<tr>
        			<td>
        				<h:outputText value="#{msg['budgetReport.budgetInput']}" />
        			</td>
        			<td colspan="3">
        				<rich:fileUpload fileUploadListener="#{budgetInputDataLoadController.listenerBudgetInput}"
			                maxFilesQuantity="1"
			                immediateUpload="true"
			                acceptedTypes="#{msg['general.validate.fileTypes']}" allowFlash="false"
			                addControlLabel="#{msg['general.search']}"
			                clearControlLabel=""
			                doneLabel="#{msg['general.done']}"
			                listHeight="60" listWidth="450"
			                progressLabel="#{msg['general.progress']}"
			                stopControlLabel="#{msg['general.stop']}"
			                uploadControlLabel="#{msg['general.uploadFile']}"
			                cancelEntryControlLabel="#{msg['general.cancel']}"
			                clearAllControlLabel="#{msg['general.cleanAll']}" transferErrorLabel="#{msg['general.error']}"
			                >
			                <a:support event="onuploadcomplete" reRender="buttonsBudgetInput" />
			            </rich:fileUpload>
        			</td>
        			<td align="center">
			            
			            <a:outputPanel id="buttonsBudgetInput">
					        <a:commandButton 
					        	action="#{budgetInputDataLoadController.validateDataInput(true,'1')}"
					        	onclick="Richfaces.showModalPanel('pnlModalProcess')"
								value="#{msg['general.validateFile']}" 
								disabled="#{not empty budgetInputDataLoadController.messageErrorBudgetInput}"
								oncomplete="Richfaces.hideModalPanel('pnlModalProcess')"
								rendered="#{not empty budgetInputDataLoadController.filesBudgetInput}"
								reRender="messagesPanelBudgetInput,errorListPanel"/>
						</a:outputPanel>
						
						<rich:spacer height="10"/>
						
				        <a:outputPanel id="messagesPanelBudgetInput"> 
				        	<div align="center">
								<a:outputPanel style="align:left" rendered="#{not empty budgetInputDataLoadController.messageErrorBudgetInput}">
							   		<h:graphicImage value="/images/error.gif" rendered="#{not empty budgetInputDataLoadController.messageErrorBudgetInput}" styleClass="errors" />
									<h:outputLabel value="#{budgetInputDataLoadController.messageErrorBudgetInput}" rendered="#{not empty budgetInputDataLoadController.messageErrorBudgetInput}" styleClass="errors"/>
									<rich:spacer height="20" rendered="#{not empty budgetInputDataLoadController.messageErrorBudgetInput}"/>
								</a:outputPanel>
								
								<a:outputPanel style="align:left" rendered="#{not empty budgetInputDataLoadController.messageInfoBudgetInput}">
							   		<h:graphicImage value="/images/msginfo.png" rendered="#{not empty budgetInputDataLoadController.messageInfoBudgetInput}" />
									<h:outputLabel value="#{budgetInputDataLoadController.messageInfoBudgetInput}" rendered="#{not empty budgetInputDataLoadController.messageInfoBudgetInput}"/>
									<rich:spacer height="20" rendered="#{not empty budgetInputDataLoadController.messageInfoBudgetInput}"/>
								</a:outputPanel>
							</div>
						</a:outputPanel>
        			</td>
        		</tr>
        		
 				<!-- insumo metas -->
       			<tr>
        			<td>
        				<h:outputText value="#{msg['budgetReport.goalsInput']}" />
        			</td>
        			<td colspan="3">
        				<rich:fileUpload fileUploadListener="#{budgetInputDataLoadController.listenerGoalsInput}"
			                maxFilesQuantity="1"
			                immediateUpload="true"
			                acceptedTypes="#{msg['general.validate.fileTypes']}" allowFlash="false"
			                addControlLabel="#{msg['general.search']}"
			                clearControlLabel=""
			                doneLabel="#{msg['general.done']}"
			                listHeight="60" listWidth="450"
			                progressLabel="#{msg['general.progress']}"
			                stopControlLabel="#{msg['general.stop']}"
			                uploadControlLabel="#{msg['general.uploadFile']}"
			                cancelEntryControlLabel="#{msg['general.cancel']}"
			                clearAllControlLabel="#{msg['general.cleanAll']}" transferErrorLabel="#{msg['general.error']}"
			                >
			                <a:support event="onuploadcomplete" reRender="buttonsGoalsInput" />
			            </rich:fileUpload>
        			</td>
        			<td align="center">
			            
			            <a:outputPanel id="buttonsGoalsInput">
					        <a:commandButton 
					        	action="#{budgetInputDataLoadController.validateDataInput(true,'2')}"
					        	onclick="Richfaces.showModalPanel('pnlModalProcess')"
								value="#{msg['general.validateFile']}" 
								disabled="#{not empty budgetInputDataLoadController.messageErrorGoalsInput}"
								oncomplete="Richfaces.hideModalPanel('pnlModalProcess')"
								rendered="#{not empty budgetInputDataLoadController.filesGoalsInput}"
								reRender="messagesPanelGoalsInput,errorListPanel"/>
						</a:outputPanel>
						
						<rich:spacer height="10"/>
						
				        <a:outputPanel id="messagesPanelGoalsInput"> 
				        	<div align="center">
								<a:outputPanel style="align:left" rendered="#{not empty budgetInputDataLoadController.messageErrorGoalsInput}">
							   		<h:graphicImage value="/images/error.gif" rendered="#{not empty budgetInputDataLoadController.messageErrorGoalsInput}" styleClass="errors" />
									<h:outputLabel value="#{budgetInputDataLoadController.messageErrorGoalsInput}" rendered="#{not empty budgetInputDataLoadController.messageErrorGoalsInput}" styleClass="errors"/>
									<rich:spacer height="20" rendered="#{not empty budgetInputDataLoadController.messageErrorGoalsInput}"/>
								</a:outputPanel>
								
								<a:outputPanel style="align:left" rendered="#{not empty budgetInputDataLoadController.messageInfoGoalsInput}">
							   		<h:graphicImage value="/images/msginfo.png" rendered="#{not empty budgetInputDataLoadController.messageInfoGoalsInput}" />
									<h:outputLabel value="#{budgetInputDataLoadController.messageInfoGoalsInput}" rendered="#{not empty budgetInputDataLoadController.messageInfoGoalsInput}"/>
									<rich:spacer height="20" rendered="#{not empty budgetInputDataLoadController.messageInfoGoalsInput}"/>
								</a:outputPanel>
							</div>
						</a:outputPanel>
        			</td>
        		</tr>
        		
 				<!-- insumo qatari -->
       			<tr>
        			<td>
        				<h:outputText value="#{msg['budgetReport.qatariInput']}" />
        			</td>
        			<td colspan="3">
        				<rich:fileUpload fileUploadListener="#{budgetInputDataLoadController.listenerQatariInput}"
			                maxFilesQuantity="1"
			                immediateUpload="true"
			                acceptedTypes="#{msg['general.validate.fileTypes']}" allowFlash="false"
			                addControlLabel="#{msg['general.search']}"
			                clearControlLabel=""
			                doneLabel="#{msg['general.done']}"
			                listHeight="60" listWidth="450"
			                progressLabel="#{msg['general.progress']}"
			                stopControlLabel="#{msg['general.stop']}"
			                uploadControlLabel="#{msg['general.uploadFile']}"
			                cancelEntryControlLabel="#{msg['general.cancel']}"
			                clearAllControlLabel="#{msg['general.cleanAll']}" transferErrorLabel="#{msg['general.error']}"
			                >
			                <a:support event="onuploadcomplete" reRender="buttonsQatariInput" />
			            </rich:fileUpload>
        			</td>
        			<td align="center">
			            
			            <a:outputPanel id="buttonsQatariInput">
					        <a:commandButton 
					        	action="#{budgetInputDataLoadController.validateDataInput(true,'3')}"
					        	onclick="Richfaces.showModalPanel('pnlModalProcess')"
								value="#{msg['general.validateFile']}" 
								disabled="#{not empty budgetInputDataLoadController.messageErrorQatariInput}"
								oncomplete="Richfaces.hideModalPanel('pnlModalProcess')"
								rendered="#{not empty budgetInputDataLoadController.filesQatariInput}"
								reRender="messagesPanelQatariInput,errorListPanel"/>
						</a:outputPanel>
						
						<rich:spacer height="10"/>
						
				        <a:outputPanel id="messagesPanelQatariInput"> 
				        	<div align="center">
								<a:outputPanel style="align:left" rendered="#{not empty budgetInputDataLoadController.messageErrorQatariInput}">
							   		<h:graphicImage value="/images/error.gif" rendered="#{not empty budgetInputDataLoadController.messageErrorQatariInput}" styleClass="errors" />
									<h:outputLabel value="#{budgetInputDataLoadController.messageErrorQatariInput}" rendered="#{not empty budgetInputDataLoadController.messageErrorQatariInput}" styleClass="errors"/>
									<rich:spacer height="20" rendered="#{not empty budgetInputDataLoadController.messageErrorQatariInput}"/>
								</a:outputPanel>
								
								<a:outputPanel style="align:left" rendered="#{not empty budgetInputDataLoadController.messageInfoQatariInput}">
							   		<h:graphicImage value="/images/msginfo.png" rendered="#{not empty budgetInputDataLoadController.messageInfoQatariInput}" />
									<h:outputLabel value="#{budgetInputDataLoadController.messageInfoQatariInput}" rendered="#{not empty budgetInputDataLoadController.messageInfoQatariInput}"/>
									<rich:spacer height="20" rendered="#{not empty budgetInputDataLoadController.messageInfoQatariInput}"/>
								</a:outputPanel>
							</div>
						</a:outputPanel>
        			</td>
        		</tr>
				
 				<!-- insumo wwi -->
       			<tr>
        			<td>
        				<h:outputText value="#{msg['budgetReport.wwiInput']}" />
        			</td>
        			<td colspan="3">
        				<rich:fileUpload fileUploadListener="#{budgetInputDataLoadController.listenerWwiInput}"
			                maxFilesQuantity="1"
			                immediateUpload="true"
			                acceptedTypes="#{msg['general.validate.fileTypes']}" allowFlash="false"
			                addControlLabel="#{msg['general.search']}"
			                clearControlLabel=""
			                doneLabel="#{msg['general.done']}"
			                listHeight="60" listWidth="450"
			                progressLabel="#{msg['general.progress']}"
			                stopControlLabel="#{msg['general.stop']}"
			                uploadControlLabel="#{msg['general.uploadFile']}"
			                cancelEntryControlLabel="#{msg['general.cancel']}"
			                clearAllControlLabel="#{msg['general.cleanAll']}" transferErrorLabel="#{msg['general.error']}"
			                >
			                <a:support event="onuploadcomplete" reRender="buttonsWwiInput" />
			            </rich:fileUpload>
        			</td>
        			<td align="center">
			            
			            <a:outputPanel id="buttonsWwiInput">
					        <a:commandButton 
					        	action="#{budgetInputDataLoadController.validateDataInput(true,'4')}"
					        	onclick="Richfaces.showModalPanel('pnlModalProcess')"
								value="#{msg['general.validateFile']}" 
								disabled="#{not empty budgetInputDataLoadController.messageErrorWwiInput}"
								oncomplete="Richfaces.hideModalPanel('pnlModalProcess')"
								rendered="#{not empty budgetInputDataLoadController.filesWwiInput}"
								reRender="messagesPanelWwiInput,errorListPanel"/>
						</a:outputPanel>
						
						<rich:spacer height="10"/>
						
				        <a:outputPanel id="messagesPanelWwiInput"> 
				        	<div align="center">
								<a:outputPanel style="align:left" rendered="#{not empty budgetInputDataLoadController.messageErrorWwiInput}">
							   		<h:graphicImage value="/images/error.gif" rendered="#{not empty budgetInputDataLoadController.messageErrorWwiInput}" styleClass="errors" />
									<h:outputLabel value="#{budgetInputDataLoadController.messageErrorWwiInput}" rendered="#{not empty budgetInputDataLoadController.messageErrorWwiInput}" styleClass="errors"/>
									<rich:spacer height="20" rendered="#{not empty budgetInputDataLoadController.messageErrorWwiInput}"/>
								</a:outputPanel>
								
								<a:outputPanel style="align:left" rendered="#{not empty budgetInputDataLoadController.messageInfoWwiInput}">
							   		<h:graphicImage value="/images/msginfo.png" rendered="#{not empty budgetInputDataLoadController.messageInfoWwiInput}" />
									<h:outputLabel value="#{budgetInputDataLoadController.messageInfoWwiInput}" rendered="#{not empty budgetInputDataLoadController.messageInfoWwiInput}"/>
									<rich:spacer height="20" rendered="#{not empty budgetInputDataLoadController.messageInfoWwiInput}"/>
								</a:outputPanel>
							</div>
						</a:outputPanel>
        			</td>
        		</tr>
				
			</table>
			
	    </rich:simpleTogglePanel>
			
		<rich:modalPanel id="pnlModalProcess" autosized="true" minWidth="200">
	   		<center>
	      		<p>#{msg['general.validatingFile']}</p>
			</center>
	    </rich:modalPanel>
	    
	    
		<rich:spacer height="20"/>
		
        <a:outputPanel id="messagesPanel"> 
        	<div align="center">
				<a:outputPanel style="align:left" rendered="#{not empty budgetInputDataLoadController.messageError}">
			   		<h:graphicImage value="/images/error.gif" rendered="#{not empty budgetInputDataLoadController.messageError}" styleClass="errors" />
					<h:outputLabel value="#{budgetInputDataLoadController.messageError}" rendered="#{not empty budgetInputDataLoadController.messageError}" styleClass="errors"/>
					<rich:spacer height="20" rendered="#{not empty budgetInputDataLoadController.messageError}"/>
				</a:outputPanel>
			</div>
		</a:outputPanel>
						
		<rich:spacer height="20"/>
        
        <div align="center">
        	<a:outputPanel id="buttonsDataLoad">
        	
				<a:commandButton 
					action="#{budgetInputDataLoadController.validate}"
					oncomplete="if(#{budgetInputDataLoadController.validForm}) Richfaces.showModalPanel('processPanel');" 
					value="#{msg['general.importData']}"
					reRender="messagesPanel"/>
					
				<rich:spacer width="20"/>

				<h:commandButton action="/data/BudgetInputDataLoad.xhtml"
					value="#{msg['general.cleanAll']}" 
					/>
					
        		<!-- 
				<a:commandButton 
					action="#{budgetInputDataLoadController.loadData(false)}"
					onclick="if(!confirm('#{msg['general.importData.confirm']}')) return false; Richfaces.showModalPanel('pnlModalProcess');" 
					value="#{msg['general.importData']}"
					oncomplete="Richfaces.hideModalPanel('pnlModalProcess')"
					reRender="errorListPanel"/>
					 -->
			</a:outputPanel>
		</div>
			


        <rich:spacer height="20"/>
        
        <a:outputPanel id="errorListPanel">
			<rich:panel rendered="#{not empty budgetInputDataLoadController.generalDataLoadErrorBeanList}">
			
		    <div id="dataErrorList">
			    <rich:dataTable id="errorMessageList"
			    			rows="#{msg['general.pagination.rowsPerSmallPage']}"
			                var="_generalDataLoadErrorBean"
			              value="#{budgetInputDataLoadController.generalDataLoadErrorBeanList}"
			           rendered="#{not empty budgetInputDataLoadController.generalDataLoadErrorBeanList}"
			           styleClass="labelBlackCenter,labelBlackLeft">
			           
			        <rich:column sortBy="#{_generalDataLoadErrorBean.rowError}">
			            <f:facet name="header">#{msg['general.row']}</f:facet>
			            <h:outputText value="#{_generalDataLoadErrorBean.rowError}"/>
			        </rich:column>
			        
			        <rich:column sortBy="#{_generalDataLoadErrorBean.errorDescription}">
			            <f:facet name="header">#{msg['general.error']}</f:facet>
			            <h:outputText value="#{_generalDataLoadErrorBean.errorDescription}"/>
			        </rich:column>
			        
			    </rich:dataTable>
			    
			    <rich:datascroller align="left" for="errorMessageList" renderIfSinglePage="false" styleClass="tableControl"
				    	maxPages="#{msg['general.pagination.maxGroupPages']}" rendered="#{not empty budgetInputDataLoadController.generalDataLoadErrorBeanList}" />

		    </div>
		    </rich:panel>
	    </a:outputPanel>
	    
	    
	    <rich:modalPanel  id="processPanel" minHeight="150" minWidth="400" 
	            height="150" width="400">
	            <f:facet name="header">
	                <h:outputText value="#{messages['general.message.confirm']}" />
	            </f:facet>
	            
	            <f:facet name="controls">
			         <h:panelGroup>
			         	<h:graphicImage value="/images/close1.png" styleClass="hidelink" id="processPanelLink"/>
			            <rich:componentControl for="processPanel" attachTo="processPanelLink" operation="hide" event="onclick"/>
			         </h:panelGroup>
			    </f:facet>
	                
	            <p>#{msg['budgetInputDataLoad.confirm.process']}</p>
	                
				<div align="center">
				
					<a:commandButton value="#{msg['general.accept']}" 
		            				   action="#{budgetInputDataLoadController.loadData(false)}"
		            				   immediate="false"
		            				   bypassUpdates="true"
		            				   onclick="#{rich:component('processPanel')}.hide(); Richfaces.showModalPanel('pnlModalProcess');"
									   oncomplete="Richfaces.hideModalPanel('pnlModalProcess');"
									   reRender="errorListPanel,messagesPanel">
		            </a:commandButton>
		            
		            <a:commandButton value="#{msg['general.cancel']}"
									   onclick="#{rich:component('processPanel')}.hide()">    
		            </a:commandButton>
		            
				</div>
	    </rich:modalPanel>

</h:form>

</ui:define>

</ui:composition>